package com.example.back.controller;


import com.example.back.dto.req.ModuleReq;
import com.example.back.dto.MenuTree;
import com.example.back.dto.resp.ModuleResp;
import com.example.back.service.SysModuleService;

import com.example.common.support.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Api(tags = "模块配置")
@RequestMapping("/DSys/Module")
public class ModuleController {

    @Resource
    private SysModuleService sysModuleService;

    @ApiOperation(value = "左边菜单栏切换", notes = "左边菜单栏切换")
    @PostMapping(value = "/getMenu")
    public Result<List<MenuTree>> getMenu(){
        return Result.success(sysModuleService.getMenu());
    }


    @ApiOperation(value = "模块配置列表", notes = "模块配置列表")
    @PostMapping(value = "/list")
    public Result<List<MenuTree>> list(){
        return Result.success(sysModuleService.list());
    }


    @ApiOperation(value = "修改和添加模块", notes = "修改和添加模块")
    @PostMapping(value = "/commitSave")
    public Result<Object> commitSave(@RequestBody ModuleReq req) {
        return Result.success(sysModuleService.commitSave(req));
    }

    @ApiOperation(value = "删除模块", notes = "删除模块")
    @PostMapping(value = "/commitDel")
    public Result<Object> commitDel(@RequestBody ModuleReq req) {
        return Result.success(sysModuleService.commitDel(req));
    }


    @ApiOperation(value = "模块详情", notes = "模块详情")
    @PostMapping(value = "/EditModuleCate")
    public Result<Object> EditModuleCate(@RequestBody ModuleReq req) {
        return Result.success(sysModuleService.EditModuleCate(req));
    }

    @ApiOperation(value = "禁用启用模块", notes = "禁用启用模块")
    @PostMapping(value = "/updateVisible")
    public Result<Object> updateVisible(@RequestBody ModuleReq req) {
        return Result.success(sysModuleService.updateVisible(req));
    }
}
